home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / exprraid.c < prev    next >
C/C++ Source or Header  |  2000-01-12  |  4KB  |  153 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4.  
  5. unsigned char *exprraid_bgcontrol;
  6.  
  7.  
  8. void exprraid_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  9. {
  10.     int i;
  11.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  12.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  13.  
  14.  
  15.     for (i = 0;i < Machine->drv->total_colors;i++)
  16.     {
  17.         int bit0,bit1,bit2,bit3;
  18.  
  19.  
  20.         bit0 = (color_prom[0] >> 0) & 0x01;
  21.         bit1 = (color_prom[0] >> 1) & 0x01;
  22.         bit2 = (color_prom[0] >> 2) & 0x01;
  23.         bit3 = (color_prom[0] >> 3) & 0x01;
  24.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  25.         bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  26.         bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  27.         bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  28.         bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  29.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  30.         bit0 = (color_prom[2*Machine->drv->total_colors] >> 0) & 0x01;
  31.         bit1 = (color_prom[2*Machine->drv->total_colors] >> 1) & 0x01;
  32.         bit2 = (color_prom[2*Machine->drv->total_colors] >> 2) & 0x01;
  33.         bit3 = (color_prom[2*Machine->drv->total_colors] >> 3) & 0x01;
  34.         *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  35.  
  36.         color_prom++;
  37.     }
  38. }
  39.  
  40.  
  41. static void drawbg(struct osd_bitmap *bitmap,int priority)
  42. {
  43.     unsigned char *map1 = &memory_region(REGION_GFX4)[0x0000];
  44.     unsigned char *map2 = &memory_region(REGION_GFX4)[0x4000];
  45.     int offs,scrolly,scrollx1,scrollx2;
  46.  
  47.  
  48.     scrolly = exprraid_bgcontrol[4];
  49.     /* TODO: bgcontrol[7] seems related to the y scroll as well, but I'm not sure how */
  50.     scrollx1 = exprraid_bgcontrol[5];
  51.     scrollx2 = exprraid_bgcontrol[6];
  52.  
  53.     for (offs = 0x100 - 1;offs >= 0;offs--)
  54.     {
  55.         int sx,sy,quadrant,base,bank;
  56.  
  57.  
  58.         sx = 16 * (offs % 16);
  59.         sy = 16 * (offs / 16) - scrolly;
  60.  
  61.         quadrant = 0;
  62.         if (sy <= -8)
  63.         {
  64.             quadrant += 2;
  65.             sy += 256;
  66.             sx -= scrollx2;
  67.         }
  68.         else
  69.             sx -= scrollx1;
  70.  
  71.         if (sx <= -8)
  72.         {
  73.             quadrant++;
  74.             sx += 256;
  75.         }
  76.  
  77.         base = (exprraid_bgcontrol[quadrant] & 0x3f) * 0x100;
  78.  
  79.         if (priority == 0 || (map2[offs+base] & 0x80))
  80.         {
  81.             bank = 2*(map2[offs+base] & 0x03)+((map1[offs+base] & 0x80) >> 7);
  82.  
  83.             drawgfx(bitmap,Machine->gfx[2+bank],
  84.                     map1[offs+base] & 0x7f,
  85.                     (map2[offs+base] & 0x18) >> 3,
  86.                     (map2[offs+base] & 0x04),0,
  87.                     sx,sy,
  88.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  89.         }
  90.     }
  91. }
  92.  
  93.  
  94.  
  95. void exprraid_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  96. {
  97.     int offs;
  98.  
  99.  
  100.     /* draw the background */
  101.     drawbg(bitmap,0);
  102.  
  103.     /* draw the sprites */
  104.     for (offs = 0;offs < spriteram_size;offs += 4)
  105.     {
  106.         int sx,sy,code,color,flipx;
  107.  
  108.         code = spriteram[offs+3] + ( ( spriteram[offs+1] & 0xe0 ) << 3 );
  109.  
  110.         sx = ((248 - spriteram[offs+2]) & 0xff) - 8;
  111.         sy = spriteram[offs];
  112.         color = (spriteram[offs+1] & 0x03) + ((spriteram[offs+1] & 0x08) >> 1);
  113.         flipx = ( spriteram[offs+1] & 0x04 );
  114.  
  115.         drawgfx(bitmap,Machine->gfx[1],
  116.                 code,
  117.                 color,
  118.                 flipx,0,
  119.                 sx,sy,
  120.                 0,TRANSPARENCY_PEN,0);
  121.  
  122.         if ( spriteram[offs+1] & 0x10 ) { /* double height */
  123.             drawgfx(bitmap,Machine->gfx[1],
  124.                     code + 1,
  125.                     color,
  126.                     flipx,0,
  127.                     sx,sy+16,
  128.                     0,TRANSPARENCY_PEN,0);
  129.         }
  130.     }
  131.  
  132.  
  133.     /* redraw the tiles which have priority over the sprites */
  134.     drawbg(bitmap,1);
  135.  
  136.  
  137.     /* draw the foreground */
  138.     for (offs = videoram_size - 1;offs >= 0;offs--)
  139.     {
  140.         int sx,sy;
  141.  
  142.         sx = offs % 32;
  143.         sy = offs / 32;
  144.  
  145.         drawgfx(bitmap,Machine->gfx[0],
  146.                 videoram[offs] + ((colorram[offs] & 7) << 8),
  147.                 (colorram[offs] & 0x10) >> 4,
  148.                 0,0,
  149.                 8*sx,8*sy,
  150.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  151.     }
  152. }
  153.